import prompt from '@system.prompt';
export default {
    data: {
        defaultTime: "",
        time: "",
        rangetext:['15', "20", "25"],
        multitext:[["a", "b", "c"], ["e", "f", "g"], ["h", "i"], ["k", "l", "m"]],
        textvalue:'default textvalue',
        datevalue:'default datevalue',
        timevalue:'default timevalue',
        datetimevalue:'default datetimevalue',
        multitextvalue:'default multitextvalue',
        containsecond:true,
        multitextselect:[1,2,0],
        datetimeselect:'2012-5-6-11-25',
        timeselect:'11:22:30',
        dateselect:'2021-3-2',
        textselect:'2'
    },
    onInit() {
        this.defaultTime = this.now();
    },
    handleChange(data) {
        this.time = this.concat(data.hour, data.minute);
    },
    now() {
        const date = new Date();
        const hours = date.getHours();
        const minutes = date.getMinutes();
        return this.concat(hours, minutes);
    },

    fill(value) {
        return (value > 9 ? "" : "0") + value;
    },

    concat(hours, minutes) {
        return `${this.fill(hours)}:${this.fill(minutes)}`;
    },
    textonchange(e) {
        this.textvalue = e.newValue;
        prompt.showToast({ message:"text:"+e.newValue+",newSelected:"+e.newSelected })
    },

    dateonchange(e) {
        this.datevalue = e.year + "-" + e.month + "-" + e.day;
        prompt.showToast({ message:"date:"+e.year+"-"+e.month+"-"+e.day })
    },

    timeonchange(e) {
        if(this.containsecond){
            this.timevalue=e.hour+":"+e.minute+":"+e.second;
            prompt.showToast({ message:"时间:" + e.hour + ":" + e.minute + ":" + e.second })
        } else {
            this.timevalue=e.hour+":"+e.minute;
            prompt.showToast({ message:"时间:" + e.hour + ":" + e.minute })
        }},

    datetimeonchange(e) {
        this.datetimevalue=e.year+"-"+e.month+"-"+e.day+" "+e.hour+":"+e.minute;
        prompt.showToast({ message:"时间:"+e.month+"-"+e.day+" "+e.hour+":"+e.minute })
    },

    multitextonchange(e) {
        this.multitextvalue=e.newValue;
        prompt.showToast({ message:"多列文本更改" + e.newValue })
    },

    popup_picker() {
        this.$element("picker_text").show();
    },
}